package org.seiya.web.controller;

import com.google.gson.Gson;
import org.seiya.jpa.repositories.StudentDao;
import org.seiya.web.controller.base.Base;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by 75306469@qq.com on 2016/4/13.
 */


@Controller
public class ApiController extends Base {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private StudentDao studentDao;
    @Autowired
    private LocalContainerEntityManagerFactoryBean entityManagerFactory;

    @RequestMapping(value = {"/"})
    @ResponseBody
    public void healthCheck(HttpServletRequest request, HttpServletResponse response) {
        logger.info(new Gson().toJson(studentDao.findOne((long) 312412)));
    }

}